Euphoria Gotchas

Every language has them, the "gotcha". Obscure parts of the syntax we must remember to avoid or work around. Things that are part of the implementation or syntax that can trap the uninitiated and the expert alike, Things that make code harder to read and present problems for programmers coming from a background in another language. In no particular order:

Base 1 or 0

The base is the number you start counting with. in Euphoria it is base 1 so a reference to s[0] would be an error. Untold hours are wasted tracking down one off errors in code that starts counting from 0 and untold hours wasted remembering to stop counting one before the end of the length of a sequence. With base 1, counting can seem more natural but you can't completely escape needing to look at code with a base 0 assumption if you use one of the many libraries written in C. Not to mention leaving room for things like line endings of one or two characters at the end of strings/arrays/sequences and null characters. Euphoria does save you from some of that worry by always managing the length and in some contexts making the line endings OS dependent while giving the programmer a consistent one character line ending unless you need to get into character by character binary control of the input or output.

The choice of base 1 or 0 influences other areas of code too. In Python for loop intended to index into an array for example: for x in range(4): print x, would output 0 1 2 3 a similar statement in Euphoria for x = 1 to 4 do print x end for would be expected to output 1 2 3 4 that is, 1 through 4 including 4.

Euphoria Basic Python C/C++ Java javascript
base 1 *base 1 base 0 base 0 base 0 base 0
  • some Basic dialect allow a base statement to choose base 1 or base 0

Block and Statement termination

Syntax rules for statement separation, indentation and statement termination: the braces in C like languages, the significant white space in Python don't mix tabs and spaces. the end statement in Euphoria.

Assignment and Compare

Some call this a gotcha, some think it's not a problem. Assignment in statements/loop counters are forbidden in Euphoria, though there are workarounds if you are determined to do this. Using '==' instead of '=' or only routines like equal() and compare() could make comparison more explicit. Some also favor a proposal to use the let syntax ':=' to make assignments more explicit too. These would be a huge syntax change if ever required in Euphoria so the discussion continues and '=' continues to serve multiple uses.

C like languages and Python use '==' for comparison. javascript even has '===' which looks like a mistake the first time you see it. Python also uses the more wordy and, or and not like Euphoria.

C especially and many C based languages allow you to do many things that other languages try to prevent you from doing as a philosophy,

Euphoria Gotchas

Some Euphoria specific implementation gotcha. Some have tickets for bugs or feature requests and numerous forum posts.

  • Euphoria built dll/so/dyn with a multitasking yield suppressed. there are technical reasons why this won't work currently.
  • can't use default parameters with routine ID callback. default parameters added in version 4+
  • difference in object() for variable uninitialized when translated. for example: <eucode>if object() = OBJ_UNASSIGNED then what() else whatnot() end if</eucode>
  • the dreaded silent exit. Euphoria should catch and report all syntax error and most if not all programming errors but there are some loopholes in the process. the silent exit can be caused by misuse of some new syntax or is a bug unreported before or reported without a way to track it down. sample code, a test routine. sometimes it only affects one platform,

Optimization

There are places in the official manual of most languages that mention considerations of optimization. You can unnecessarily slow down your program by using += or + instead of append() in at least Python and Euphoria, Though some implementations may target these statements for optimization already or have plans to add such optimizations automatically while still trying to make you aware of the potential problem and for anyone using older versions.

All languages and other software have the huge gotcha of version changes. Incompatibility and required maintenance of tools. Input.Output file format changes. Computer languages can mitigate some of these changes by accommodating older syntax and or providing warnings while still allowing some syntax from the past or reserving keywords for the future.

Cross Platform Things:

  • GUI toolkits that work in windows only
  • GUI toolkits installed by default in *nix hard or impossible to install in windows or mac
  • path to HOME
  • *

maybe eventually the creole <TOC> will work to help organize this page. please add your own personal favorite gotcha for Euphoria or other languages.

Search



Quick Links

User menu

Not signed in.

Misc Menu